package cn.edu.yzu.scholarship.render;

import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.jasper.constant.ImageType;

import com.jfinal.render.Render;

public class JRImageRender extends Render {

	private static final long serialVersionUID = -4021916966974528920L;
	
	private JasperReportBuilder builder = null;

	public JRImageRender(JasperReportBuilder builder) {
		this.builder = builder;
	}

	@Override
	public void render() {
		try {
			builder.toImage(response.getOutputStream(), ImageType.JPG);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
